package service

import (
	"awesomeProject/app/request"
	"awesomeProject/app/response"
	"awesomeProject/global"
	"context"
	"go.mongodb.org/mongo-driver/bson"
)

type ShopDataSrv struct{}

func (s ShopDataSrv) GetByShopId(req request.Statistics) response.Resp {
	var shopData map[string]interface{}
	filter := bson.D{bson.E{Key: "shop_id", Value: req.ShopId}}
	err := global.MongoDB.Collection("shop_data").FindOne(context.TODO(), filter).Decode(&shopData)
	if err != nil {

		return response.ErrQuery.SetMsg(err.Error())
	}
	return response.OK.WithData(shopData)
}
